package com.sky.controller.admin;

import com.sky.result.Result;
import com.sky.service.WorkspaceService;
import com.sky.vo.BusinessDataVO;
import com.sky.vo.DishOverViewVO;
import com.sky.vo.OrderOverViewVO;
import com.sky.vo.SetmealOverViewVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;

@RestController
@Slf4j
@RequestMapping("/admin/workspace")
public class WorkspaceController {
    @Autowired
    private WorkspaceService workspaceService;

    @GetMapping("/businessData")
    public Result<BusinessDataVO> getBusinessData() {
        log.info("getBusinessData,time:{}", LocalDateTime.now());
        //时间应该是这一天
        LocalDateTime begin=LocalDateTime.of(LocalDate.now(), LocalTime.MIN);
        LocalDateTime end=LocalDateTime.of(LocalDate.now(), LocalTime.MAX);
        BusinessDataVO businessDataVO = workspaceService.getBusinessData(begin,end);
        return  Result.success(businessDataVO);
    }


    @GetMapping("/overviewSetmeals")
    public Result<SetmealOverViewVO> getOverviewSetmeals() {
        log.info("getOverviewSetmeals, time:{}", LocalDateTime.now());
        //时间应该这一天之前
//        LocalDateTime begin=LocalDateTime.of(LocalDate.now(), LocalTime.MIN);
        LocalDateTime end=LocalDateTime.of(LocalDate.now(), LocalTime.MAX);
        SetmealOverViewVO setmealOverView= workspaceService.getOverviewSetmeals(null, end);
        return Result.success(setmealOverView);
    }

    @GetMapping("/overviewDishes")
    public Result<DishOverViewVO> getOverviewDishes() {
        log.info("getOverviewDishes, time:{}", LocalDateTime.now());
        //时间应该这一天之前
//        LocalDateTime begin=LocalDateTime.of(LocalDate.now(), LocalTime.MIN);
        LocalDateTime end=LocalDateTime.of(LocalDate.now(), LocalTime.MAX);
        DishOverViewVO dishOverView= workspaceService.getOverviewDishes(null,end);
        return Result.success(dishOverView);
    }

    @GetMapping("/overviewOrders")
    public Result<OrderOverViewVO> getOverviewOrders() {
        log.info("getOverviewOrders, time: {}",LocalDateTime.now());
        //时间应该是这一天
        LocalDateTime begin=LocalDateTime.of(LocalDate.now(), LocalTime.MIN);
        LocalDateTime end=LocalDateTime.of(LocalDate.now(), LocalTime.MAX);
        OrderOverViewVO orderOverView= workspaceService.getOverviewOrders(begin,end);
        return Result.success(orderOverView);
    }




}
